/**
 * https://leetcode.cn/problems/combination-sum-iv/submissions/562525001/
 * 377. 组合总和 Ⅳ
 * medium 陈贝纯 2024.09.07
 * 经典线性
 */

class Solution {
public:
    int combinationSum4(vector<int>& nums, int target) {
        vector<long long> dp(target+1);
        dp[0]=1;
        for(int i=1;i<=target;++i){
            for(auto x:nums){
                if(i>=x&&dp[i-x]<INT_MAX-dp[i])
                dp[i]+=dp[i-x];
            }
        }
        return dp[target];
    }
};